# 导包
from common.base import *


class Shopcart(Base):
    # TODO 2 定位首页购物车按钮
    def btn_shopcart_index(self):
        self.click((By.XPATH, '//*[@id="ECS_CARTINFO"]/a'))

    # 定位清空购物车
    def btn_shopcart_clear(self):
        self.click((By.XPATH, '//*[@id="formCart"]/table[2]/tbody/tr/td[2]/input[1]'))
        #

    # 定位更新购物车
    def btn_shopcart_updata(self):
        self.click((By.XPATH, '//*[@id="formCart"]/table[2]/tbody/tr/td[2]/input[2]'))

    # 定位继续购物
    def btn_shoping(self):
        self.click((By.XPATH, '/html/body/div[6]/div[1]/table/tbody/tr/td[1]/a/img'))

    # 定位结账
    def btn_shopcart_pay(self):
        self.click((By.XPATH, '/html/body/div[6]/div[1]/table/tbody/tr/td[2]/a/img'))

    # 定位商品
    def btn_shop_thing(self):
        self.click((By.XPATH, '/html/body/div[6]/div/div/div[2]/div[2]/div/a[1]/div[1]/img'))

    # 定位立即购买
    def btn_shop_buy(self):
        self.click((By.XPATH, '//*[@id="ECS_FORMBUY"]/ul/li[7]/table/tbody/tr/td[1]/a/img'))

    # 点击数量框
    def count_click(self):
        self.click((By.CLASS_NAME, 'inputBg'))

    # 定位数量清空(立即购买后执行)
    def count_clear(self):
        self.clear_text((By.CLASS_NAME, 'inputBg'))

    # 修改数量(数量清空后执行)
    def count_ipt(self, text):
        self.send_keys((By.CLASS_NAME, 'inputBg'), text)

    # 购物车删除商品
    def shop_delete(self):
        self.click((By.XPATH, '//*[@id="formCart"]/table[1]/tbody/tr[2]/td[7]/a[1]'))

    # 获取删除商品的确认弹窗
    def get_alert(self):
        self.switch_to_alert()




